home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_3.arc / HEAP4 < prev    next >
Text File  |  1988-04-05  |  1KB  |  58 lines

  1. Borland International's HEAP4.  Copyright 1988 Borland
  2. International.  No commercial use of this code without express
  3. permission from Borland International.
  4.  
  5. Run this one under TP4:
  6.  
  7.   program Heap4; {$R-}
  8.   { Compile and run under both Turbo Pascal 3.0 and 4.0.
  9.     Runs faster under 4.0.
  10.   }
  11.  
  12.   const
  13.     ArraySize = 1000;
  14.  
  15.   type
  16.     Byte3 = array[1..3] of Byte;
  17.     Byte5 = array[1..5] of Byte;
  18.     Byte7 = array[1..7] of Byte;
  19.     Byte9 = array[1..9] of Byte;
  20.  
  21.     Ptr3 = ^Byte3;
  22.     Ptr5 = ^Byte5;
  23.     Ptr7 = ^Byte7;
  24.     Ptr9 = ^Byte9;
  25.  
  26.   var
  27.     P5: array[1..ArraySize] of Ptr5;
  28.     P7: array[1..ArraySize] of Ptr7;
  29.  
  30.     Q3: array[1..ArraySize] of Ptr3;
  31.     Q9: array[1..ArraySize] of Ptr9;
  32.  
  33.     I: Integer;
  34.  
  35.     Timer: Integer absolute $40:$6C;
  36.     Start: Integer;
  37.  
  38.   begin
  39.     WriteLn('Start');
  40.     Start := Timer;
  41.  
  42.     for I := 1 to ArraySize do         { allocation loop }
  43.     begin
  44.       New(P5[I]);
  45.       New(P7[I]);
  46.     end;
  47.  
  48.     for I := ArraySize downto 1 do     { fragmentation loop }
  49.     begin
  50.       Dispose(P5[I]);
  51.       New(Q3[I]);
  52.       New(Q9[I]);
  53.       Dispose(P7[I]);
  54.     end;
  55.  
  56.     Writeln('Done in ',(Timer-Start)/18.2:0:1,' seconds.');
  57.   end.
  58.